<form>
<div class="layuimini-main">
<div class="layui-form layuimini-form">
    <div class="layui-form-item">
        <label class="layui-form-label required">用户ID</label>
        <div class="layui-input-block">
            <input type="text" name="id" lay-verify="required" lay-reqtext="用户名不能为空" placeholder="请输入要修改的用户的ID" value="" class="layui-input">
            <tip>提示：用户ID是唯一的，不可随意修改</tip>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">昵称</label>
        <div class="layui-input-block">
            <input type="text" name="name" lay-verify="required" lay-reqtext="用户名不能为空" placeholder="请输入修改后的昵称" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">性别</label>
        <div class="layui-input-block">
            <input type="radio" name="sex" value="女" title="女" checked="">
            <input type="radio" name="sex" value="男" title="男" >
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">所在地区</label>
        <div class="layui-input-block">
            <input type="text" name="location" placeholder="请输入所在地区" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">个性签名</label>
        <div class="layui-input-block">
            <input type="text" name="sign" placeholder="请输入个性签名" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn"> 保 存 </button>
        </div>
    </div>
</div>
</div>
</form>
<script>
    layui.use(['form', 'table'], function () {
        var form = layui.form,
            layer = layui.layer,
            table = layui.table,
            $ = layui.$;

        // var id1 =  $('#id').val();
        // var name1 = $('#name').val();
        // var location1 = $('#location').val();
        // var sign1 = $('#sign').val();


        /**
         * 初始化表单，要加上，不然刷新部分组件可能会不加载
         */
        form.render();

        // 当前弹出层，防止ID被覆盖
        var parentIndex = layer.index;

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            layer.confirm('已保存', function (index){
                var sex1 = data.field.sex;
                var id1 =  data.field.id;
                var name1 = data.field.name;
                var location1 = data.field.location;
                var sign1 = data.field.sign;
                // console.log(id1+"  "+name1+"  "+location1+"   "+sign1+"   "+sex1);
                $.post('/admin/changeuserinformation',{id: id1,sex: sex1,name: name1,sign:sign1,location:location1},function (data){
                    // layer.msg(data.msg);
                    layer.close(index);
                    layer.close(parentIndex);
                });
            });

            return false;
        });

    });
</script>
